/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ucab.desarrollo.viajesbook.actions;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import ucab.desarrollo.viajesbook.TwitterAdmin;
import ucab.desarrollo.viajesbook.TwitterGestion;

/**
 *
 * @author isak
 */
public class EnviarTweetAction extends ActionSupport
{
    private String status="algo";
    String consumer = "9yxhHX5KlvZzgjzBuo4w";
    String consumerSecret= "ICRy3ACcHevmVuQ4XesExwlF2gorkYmvdVaCzj22w";

    @Override
    public String execute() throws Exception
    {
             Map session = ActionContext.getContext().getSession();
             TwitterGestion tw  = (TwitterGestion)session.get("twitter");
             Twitter twitter = new TwitterFactory().getInstance();
	     twitter.setOAuthConsumer(consumer, consumerSecret);
             twitter.setOAuthAccessToken(tw.getTokenAcceso());
             Status status2 = twitter.updateStatus(status);
             String usuario = status2.getText();
        return SUCCESS;
    }

    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }



    
}
